﻿using B.S.Data.MES.API.Applications.QualityManagement.ExamineTypeModel.Command;
using B.S.Domain.BasicData.QualityManagement;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.QualityManagement.ExamineTypeModel.CommandHandler
{
    public class UpdateExamineTypeCommandHandler : IRequestHandler<UpdateExamineTypeCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<ExamineType> _examintypeRepository;
        public UpdateExamineTypeCommandHandler(IBaseRepository<ExamineType> examintypeRepository)
        {
            _examintypeRepository = examintypeRepository;
        }
        public Task<APIRequst<int>> Handle(UpdateExamineTypeCommand request, CancellationToken cancellationToken)
        {
            APIRequst<int> result = new APIRequst<int>();
            result.Code = RequstCode.成功;
            result.Msg = RequstCode.成功.ToString();

            ExamineType type = new ExamineType();
            type.ExamineId = request.ExamineId;
            type.ExamineNo = request.ExamineNo;
            type.ExamineName = request.ExamineName;
            type.ExamineDesc = request.ExamineDesc;
            type.CreateName = request.CreateName;
            type.UpdateTime =DateTime.Now;
           

            _examintypeRepository.Update(type);

            return Task.FromResult(result);
        }
    }
}
